﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WorkflowManager.aspx.cs" Inherits="SaaS.WorkflowManager" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Workflow Manager</title>
</head>
<body background="https://minisaas.blob.core.windows.net/img/bg.jpg">
    <form id="form1" runat="server">
    <div>
    
        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/ControlPanel.aspx">Return to Control Panel</asp:HyperLink>
        <br />
        <br />
        <asp:Label ID="Label1" runat="server" Text="Workflow Base:"></asp:Label>
        <br />
        <asp:DropDownList ID="ddlSystemWorkflows" runat="server" AutoPostBack="True" 
            Height="22px" onselectedindexchanged="ddlSystemWorkflows_SelectedIndexChanged" 
            Width="187px">
        </asp:DropDownList>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
            style="margin-left: 10px" Text="Add Workflow..." />
        <br />
        <asp:Label ID="Label2" runat="server" Text="Custom Workflow Name:"></asp:Label>
        <asp:TextBox ID="txtCustomName" runat="server" Enabled="False" 
            style="margin-left: 45px" Width="176px"></asp:TextBox>
        <br />
        <asp:Label ID="Label3" runat="server" Text="Custom Workflow Description:"></asp:Label>
        <asp:TextBox ID="txtCustomDescription" runat="server" Enabled="False" 
            ontextchanged="TextBox2_TextChanged" style="margin-left: 13px" Width="176px"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="Button2" runat="server" onclick="Button2_Click" 
            style="margin-left: 204px" Text="Edit Workflow..." Width="177px" />
        <br />
        <asp:DropDownList ID="ddlTenantWorkflows" runat="server" Height="20px" 
            Width="187px">
        </asp:DropDownList>
        <asp:Button ID="Button3" runat="server" onclick="Button3_Click" 
            style="margin-left: 17px" Text="Execute Workflow..." />
        <br />
        <asp:Button ID="Button4" runat="server" onclick="Button4_Click" 
            style="margin-left: 204px" Text="Delete Workflow" Width="177px" />
        <br />
        <br />
        <asp:Label ID="lblErr" runat="server" ForeColor="Red"></asp:Label>
        <br />
        <br />
        <asp:Label ID="Label4" runat="server" Text="Custom Services"></asp:Label>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            CellPadding="4" DataKeyNames="Service_ID" DataSourceID="SqlDataSource1" 
            ForeColor="#333333" GridLines="None" onrowcommand="GridView1_RowCommand" 
            onrowdeleting="GridView1_RowDeleting" 
            style="margin-top: 0px">
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <asp:BoundField DataField="Service_ID" HeaderText="ID" ReadOnly="True" 
                    SortExpression="Service_ID" />
                <asp:BoundField DataField="Service_Name" HeaderText="Name" 
                    SortExpression="Service_Name" />
                <asp:BoundField DataField="Service_Function_Name" 
                    HeaderText="Function Name" SortExpression="Service_Function_Name" />
                <asp:BoundField DataField="Service_Path" HeaderText="Path" 
                    SortExpression="Service_Path" />
                <asp:BoundField DataField="Service_Description" 
                    HeaderText="Description" SortExpression="Service_Description" />
                <asp:ButtonField CommandName="Del" Text="Delete" />
                <asp:CommandField ShowEditButton="True" />
            </Columns>
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:MiniSaaSConnectionString %>" 
            
            SelectCommand="SELECT [Service_ID], [Service_Name], [Service_Path], [Service_Function_Name], [Service_Description] FROM [SERVICE] WHERE ([Login_ID] = @Login_ID)" 
            ondeleting="SqlDataSource1_Deleting" 
            DeleteCommand="DELETE FROM [SERVICE] WHERE [Service_ID] = @Service_ID" 
            InsertCommand="INSERT INTO [SERVICE] ([Service_ID], [Service_Name], [Service_Path], [Service_Function_Name], [Service_Description]) VALUES (@Service_ID, @Service_Name, @Service_Path, @Service_Function_Name, @Service_Description)" 
            
            UpdateCommand="UPDATE [SERVICE] SET [Service_Name] = @Service_Name, [Service_Path] = @Service_Path, [Service_Function_Name] = @Service_Function_Name, [Service_Description] = @Service_Description WHERE [Service_ID] = @Service_ID">
            <SelectParameters>
                <asp:SessionParameter DefaultValue="-1" Name="Login_ID" SessionField="LoginID" 
                    Type="Int32" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="Service_ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Service_Name" Type="String" />
                <asp:Parameter Name="Service_Path" Type="String" />
                <asp:Parameter Name="Service_Function_Name" Type="String" />
                <asp:Parameter Name="Service_Description" Type="String" />
                <asp:Parameter Name="Service_ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Service_ID" Type="Int32" />
                <asp:Parameter Name="Service_Name" Type="String" />
                <asp:Parameter Name="Service_Path" Type="String" />
                <asp:Parameter Name="Service_Function_Name" Type="String" />
                <asp:Parameter Name="Service_Description" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>
